package com.xinsoft.controller.basic;


import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
@RabbitListener(queues = "my_queue")//监听的队列名称
//@RabbitListener(queuesToDeclare = @Queue("simple_queue"))  //如果simple_queue队列不存在，则创建simple_queue队列。默认队列是持久化，非独占式的
public class SimpleConsumer {

    //消费者如果监听到消息队列有消息传入，则会自动消费
    @RabbitHandler
    public void receive(Map message) {
        System.out.println("简单模式 -> 消费者收到map类型消息  : " + message.toString());
    }

    @RabbitHandler
    public void receive2(String message) {
        System.out.println("简单模式 -> 消费者收到string类型消息  : " + message.toString());
    }
}
